package ru.mcfr.oxygen.framework.operations.highlight;

import ro.sync.ecss.extensions.commons.ui.OKCancelDialog;

import javax.swing.*;

/**
 * Dialog used for changing the current review author
 */
public class ChangeReviewAuthorDialog extends OKCancelDialog {
    /**
     * Combo box containing all possible author names
     */
    private JComboBox authorNamesComboBox;

    /**
     * Constructor.
     *
     * @param parentFrame The parent frame.
     * @param title       The dialog title.
     * @param authorNames All the possible author names.
     */
    public ChangeReviewAuthorDialog(
            JFrame parentFrame,
            String title,
            String[] authorNames) {
        super(parentFrame, title, true);
        // Add label
        add(new JLabel("Choose Review Author: "));
        // Add the combobox containing possible author names
        authorNamesComboBox = new JComboBox(authorNames);
        add(authorNamesComboBox);
    }

    /**
     * Show the dialog.
     */
    public void showDialog() {
        setLocationRelativeTo(null);
        pack();
        setVisible(true);
    }

    /**
     * Get the selected author name.
     *
     * @return The selected author name.
     */
    public String getSelectedAuthorName() {
        return (String) authorNamesComboBox.getSelectedItem();
    }
}
